package com.balakitbbs.controller;

import org.springframework.beans.factory.annotation.Autowired; 
import java.util.*;               
import org.springframework.stereotype.Controller;               
import org.springframework.web.bind.annotation.PathVariable;               
import org.springframework.web.bind.annotation.RequestMapping;               
import org.springframework.web.servlet.ModelAndView;               
import com.balakitbbs.page.Page;               
import com.balakitbbs.page.SearchPageUtil;               
import com.balakitbbs.service.Bala_freindService;
import com.balakitbbs.entity.Bala_freind;
   /**
    * bala_freind Controller类
    */ 
@Controller
public class Bala_freindController{
	@Autowired
	private Bala_freindService bala_freindservice;

//增加朋友表
@RequestMapping("/page/{pageIndex}/{pageSize}/addBala_freind")
public String addBala_freind(Bala_freind bala_freind,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_freind.setCdate(new Date());
	bala_freind.setId(UUID.randomUUID().toString());
	bala_freindservice.addBala_freind(bala_freind);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_freind.do";
}


//删除朋友表
@RequestMapping("/page/{Id}/{pageIndex}/{pageSize}/delBala_freind")
public String delBala_freind(@PathVariable String Id,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_freindservice.delBala_freind(Id);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_freind.do";
}


//修改朋友表
@RequestMapping("/page/{pageIndex}/{pageSize}/updateBala_freind")
public String updateBala_freind(Bala_freind bala_freind,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_freind.setUdate(new Date());
	bala_freindservice.updateBala_freind(bala_freind);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_freind.do";
}


//查询朋友表
@RequestMapping("/page/{pageIndex}/{pageSize}/selectBala_freind")
public ModelAndView selectBala_freinds(Bala_freind bala_freind,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	ModelAndView modelAndView = new ModelAndView();
	int selectBala_freindCount = bala_freindservice.selectBala_freindsByPOJOCount(bala_freind);
	Page page = new Page(pageIndex, pageSize, selectBala_freindCount);
	SearchPageUtil spu = new SearchPageUtil();
	spu.setPage(page);
	modelAndView.addObject("data", bala_freindservice.selectBala_freindsByPojoPage(spu, bala_freind));
	modelAndView.addObject("page", page);
	modelAndView.addObject("s", 1);
	modelAndView.addObject("po", new Bala_freind());
	modelAndView.setViewName("/WEB-INF/page/bala_freind.jsp");
	return modelAndView;
}

}

